$(function(){
    var mySwiper = $('.swiper-container').swiper({
        loop: true,
        autoplay: 5000,
        simulateTouch: false,
        autoHeight:true,
        prevButton:'.swiper-button-prev',
        nextButton:'.swiper-button-next',
        calculateHeight: true
    });
    $('.swiper-button-prev').on('click',function(){
        mySwiper.swipePrev();
    });
    $('.swiper-button-next').on('click',function(){
        mySwiper.swipeNext();
    });
    $('.myscroll').myScroll({
        speed: 40, //数值越大，速度越慢
        rowHeight: 31 //li的高度
    });
    $('.footer-icp').on('click', function () {
        window.open("http://www.miitbeian.gov.cn");
    });

    $('#feed-submit').on('click', function() {
        var fn = $('.feed-name').val();
        var ft = $('.feed-tel').val();
        var ff = $('.feed-firm').val();
        var fp = $('.feed-product').val();
        if (fn === '') {
            alert('姓名不能为空')
        } else if (ft === '') {
            alert('电话不能为空')
        } else if (ff === '') {
            alert('公司不能为空')
        } else {
            var data = {}
            data.company=ff;
            data.main_product=fp;
            data.name=fn;
            data.mobile=ft;
            data.position='123';
            data.user_type='供应商';
            jQuery.support.cors = true;
            $.ajax({
                  url: 'http://47.104.164.100/node/add_user_test',
                  data: data,
                  type: 'POST',
                  success: function(data){
                      var data = JSON.parse(data)
                      if(data) {
                          if(data.code === -1) {
                              alert('请填写正确信息')
                          }
                          if(data.code === 200) {
                              alert('您的信息已经提交成功, 我们工作人员会尽快与您取得联系')
                          }
                      }
                  }
              })
        }

    });
    $('#need-submit').on('click', function() {
        var nn = $('.need-name').val();
        var nt = $('.need-tel').val();
        var nf = $('.need-firm').val();
        var np = $('.need-product').val();
        if (nn === '') {
            alert('姓名不能为空')
        } else if (nt === '') {
            alert('电话不能为空')
        } else {
            var data = {}
            data.company=nf;
            data.get_product=np;
            data.name=nn;
            data.mobile=nt;
            data.position='123';
            data.user_type='采购商';
          jQuery.support.cors = true;
            $.ajax({
                type: 'POST',
                url: 'http://47.104.164.100/node/add_user_test',
                data: data,
                success: function(data){
                    var data = JSON.parse(data)
                    if(data.code === -1) {
                        alert('请填写正确信息')
                    }
                    if(data.code === 200) {
                        alert('您的信息已经提交成功, 我们工作人员会尽快与您取得联系')
                    }
                }
            })
        }

    });
})
